/* ****************************************************************************
 *
 * Copyright (c) Microsoft Corporation. 
 *
 * This source code is subject to terms and conditions of the Microsoft Public License. A 
 * copy of the license can be found in the License.html file at the root of this distribution. If 
 * you cannot locate the  Microsoft Public License, please send an email to 
 * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
 * PARTICULAR PURPOSE.
 * ***************************************************************************/

#if !defined(AFX_FIELDFCN_H__C1F26C23_FAFD_4974_A773_5480CC6D9523__INCLUDED_)
#define AFX_FIELDFCN_H__C1F26C23_FAFD_4974_A773_5480CC6D9523__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Field.h"

namespace contour
{

/*! \brief A 2D function.
The user must set the pointer to the function. 

\ingroup FieldGroup

*/
template<class T>
class TFieldFcn : public TField<T>
{
public:
	TFieldFcn(T (*pFieldFcn)(T, T) = NULL): m_pFieldFcn(pFieldFcn){};
	virtual ~TFieldFcn(){};

	//! Setting the pointer to the field function.
	void SetFieldFcn(T (*pFieldFcn)(T, T))		{ m_pFieldFcn = pFieldFcn;};

	//! Evaluation function at (x,y)
	virtual T Eval(T x, T y)		{	if (m_pFieldFcn) return (*m_pFieldFcn)(x,y); else return 0;};
protected:
	//! Pointer to the field function
	T (*m_pFieldFcn)(T x, T y); // pointer to F(x,y) function
};

};
#endif // !defined(AFX_FIELDFCN_H__C1F26C23_FAFD_4974_A773_5480CC6D9523__INCLUDED_)
